<%@ page import="java.util.List" %>
<%@ page import="com.candy.pojo.Student" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Date" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/8/18
  Time: 9:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
  <head>
    <title>$Title$</title>
  </head>
  <body>
    <%
      List<Student> lst=new ArrayList<>();
      Student stu0=new Student();
      stu0.setStuAge(19);
      stu0.setStuName("tom");
      lst.add(stu0);
      lst.add(new Student("lily",21));
      lst.add(new Student("zhangsan",24));
      session.setAttribute("lstStu",lst);
      session.setAttribute("dateNow",new Date());
    %>
  <br />
  <c:forEach items="${sessionScope.lstStu}" var="eachValue" varStatus="stat">
    ${stat.index+1}
    姓名: ${eachValue.stuName}   年龄:${eachValue.stuAge}
    <br>
  </c:forEach>
  <br>
  使用foreach标签进行数数：
  <br>
  <c:forEach begin="1" end="100" var="eachV" step="2">
    <c:out value="${eachV}" ></c:out>
  </c:forEach>
  <br />
  <c:forEach items="${sessionScope.lstStu}" var="eachValue" varStatus="stat">
    ${stat.index+1}
    姓名: ${eachValue.stuName}   年龄:${eachValue.stuAge}
    <c:choose>
      <c:when test="${eachValue.stuAge}>=18">
        成年人
      </c:when>
      <c:otherwise>
        未成年
      </c:otherwise>
    </c:choose>
    <br>
  </c:forEach>
  <br>
    ${sessionScope.dateNow}
  <br>
    当前时间:<fmt:formatDate value="${sessionScope.dateNow}" ></fmt:formatDate>
  <br>
    当前时间:<fmt:formatDate value="${sessionScope.dateNow}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate>
  </body>
</html>
